package util;

import java.awt.Color;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

/**
 *
 * @author Silvanei S
 */
public class FieldListener implements FocusListener{

    @Override
    public void focusGained(FocusEvent e) {
        Object o = e.getSource();  
  
        if ( o instanceof JTextField ) { 
              
            JTextField f = ( JTextField ) o;  
            f.setBackground( new Color( 255, 255, 200 ) );  
                          
        } 
        
        if ( o instanceof JRadioButton) {
            
            JRadioButton f = ( JRadioButton ) o;  
            f.setBackground( new Color( 255, 255, 200 ) );  
            
        }
    }

    @Override
    public void focusLost(FocusEvent e) {
        Object o = e.getSource();  
          
        if ( o instanceof JTextField ) {  
              
            JTextField f = ( JTextField ) o;  
            f.setBackground( new Color( 255, 255, 255 ) );  
              
        }
        
        if ( o instanceof JRadioButton) {
            
            JRadioButton f = ( JRadioButton ) o;  
            f.setBackground( new Color( 255, 255, 255 ) );
            
        }
    }
    
}
